/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tk.eigh.ksvg.renderer.shape;


import tk.eigh.ksvg.renderer.SVGShapeRenderer;
import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import ksvg.shape.Polygon;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import tk.eigh.ksvg.renderer.SVGRendererUtils;

/**
 *
 * @author nt
 */
@JSFRenderer(renderKitId="SVG",type="SVGPolygonRenderer",family="shape.Polygon")
public class SVGPolygonRenderer extends SVGShapeRenderer{

    protected final static String TAG_NAME = "polygon";

    @Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        super.encodeBegin(context, component);

        ResponseWriter writer = context.getResponseWriter();
        Polygon polygon = (Polygon) component;
        writer.startElement(TAG_NAME, component);
        renderCommonAttributes(writer, component, context);
        SVGRendererUtils.renderImplementedAttributes(component, writer);
        writer.writeAttribute("points", polygon.getPoints(), "points");
    }

    @Override
    public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
        super.encodeEnd(context, component);
        context.getResponseWriter().endElement(TAG_NAME);
    }

}
